﻿<Modal Visible="@Visible"
       OnOk="HandleOk"
       OnCancel="HandleCancel"
       Title="请选择图标"
       Draggable="true"
       DragInViewport="true">
    <CavIconPanel @bind-RadioValue="IconValue"></CavIconPanel>
</Modal>


@code{
    [Parameter]
    public bool Visible { get; set; }
    [Parameter]
    public EventCallback<bool> VisibleChanged { get; set; }

    [Parameter]
    public string IconValue { get; set; }
    [Parameter]
    public EventCallback<string> IconValueChanged { get; set; }

    private async void HandleOk(MouseEventArgs e)
    {
        Visible = false;
        if (IconValueChanged.HasDelegate)
        {
            await IconValueChanged.InvokeAsync(IconValue);
        }
        if (VisibleChanged.HasDelegate)
        {
            await VisibleChanged.InvokeAsync(Visible);
        }
        StateHasChanged();
    }

    private async void HandleCancel(MouseEventArgs e)
    {
        Visible = false;
        if (VisibleChanged.HasDelegate)
        {
            await VisibleChanged.InvokeAsync(Visible);
        }
    }
}